package main

import (
	"encoding/json"
	"fmt"
)

type Student struct {
	ID     int
	Gender string
	//name   string //私有属性不能被json包访问
	Name string
	Sno  string
}

func main() {
	//json字符串
	str := `{"ID":27,"Gender":"男","Name":"李四","Sno":"9527"}`
	var s1 Student
	err := json.Unmarshal([]byte(str), &s1)

	if err != nil {
		panic(err)
	}

	fmt.Printf("%#v\n", s1) //main.Student{ID:27, Gender:"男", Name:"李四", Sno:"9527"}
	fmt.Println(s1.Name)
}
